#include "Stdafx.h"
#include "ViewPort.h"

namespace Reign
{namespace Video
{namespace D3D10
{
	#pragma region Constructors
	ViewPort::ViewPort(VideoI^ video)
	{
		this->video = (Video^)video;
	}

	ViewPort::ViewPort(VideoI^ video, int x, int y, int width, int height)
	: ViewPortI(x, y, width, height)
	{
		this->video = (Video^)video;
	}

	ViewPort::ViewPort(VideoI^ video, I32::Vector2 location, I32::Vector2 size)
	: ViewPortI(location, size)
	{
		this->video = (Video^)video;
	}

	ViewPort::ViewPort(VideoI^ video, I32::Bound2 bound)
	: ViewPortI(bound)
	{
		this->video = (Video^)video;
	}
	#pragma endregion

	#pragma region Methods
	void ViewPort::Apply(RenderTargetI^ renderTarget)
	{
		if (renderTarget == nullptr)
		{
			D3D10_VIEWPORT viewPort =
			{
				Location.X, video->lastWindowFrameSize.Y - Size.Y - Location.Y,
				Size.X, Size.Y,
				0.0f, 1.0f
			};

			video->Device->RSSetViewports(1, &viewPort);
		}
		else
		{
			D3D10_VIEWPORT viewPort =
			{
				Location.X, renderTarget->Size.Y - Size.Y - Location.Y,
				Size.X, Size.Y,
				0.0f, 1.0f
			};

			video->Device->RSSetViewports(1, &viewPort);
		}
	}
	#pragma endregion
}
}
}